package cs470.kalman;

import java.awt.GridLayout;
import java.util.Map;

import javax.swing.JFrame;

import com.panayotis.gnuplot.GNUPlot;
import com.panayotis.gnuplot.JavaPlot;
import com.panayotis.gnuplot.plot.Plot;
import com.panayotis.gnuplot.terminal.SVGTerminal;

import cs470.agent.KalmanAgent;
import Code.BZRClient;
import Code.DisplayPanel;
import Code.Environment;
import Code.FileHelper;
import Code.Point;

public class RunShooter {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		if(args.length < 2){
			args = new String[]{"localhost", "50100"};
			System.out.println(args[0]);
		}
		
		final BZRClient client = new BZRClient(args[0], Integer.parseInt(args[1]));

		//TODO: dynamic worldsize;
		final Point location = client.getOtherTanks().get(0).getLocation();
		final Map<String, String> constants = client.getConstants();
		final int size = Integer.parseInt(constants.get("worldsize"));
		
		final JFrame jFrame = new JFrame("McNeill-Bailey Kalman Filter");
		jFrame.setBounds(100, 100, size, size);
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jFrame.setLayout(new GridLayout(1, 2));
		
		final KalmanPanel panel1 = new KalmanPanel(false);
//		final KalmanPanel panel2 = new KalmanPanel(true);
		jFrame.add(panel1);
//		jFrame.add(panel2);
		
		jFrame.setVisible(true);
		
		final KalmanFilter filter = new KalmanFilter(5, Matrix.getMatrixFromPoint(location), 800, 800, panel1);
		
		final KalmanAgent agent = new KalmanAgent(client, filter);
		
		agent.run();
	}

}
